#include <stdio.h>
#define yang 2.05
#define tian 1.15
#define hu 	 1.09
#define rate 0.05
#define low  6.5
#define medi 14
#define high 1
int eatline(void);
int main(void)
{
	char input;
	double w_yang=0.0,w_hu=0.0,w_tian=0.0,w_all,w,sum,trans,tic;
	printf("****************************\n");
	printf(" Please enter the choice\n");
	printf("a-yang:2.05$\tb-tian:1.15$\tc-hu:1.09$\tq-exit\n");
	
	while(1){
		while((input = getchar())<'a' || (input>'c') && (input != 'q'))
		{
			printf("Please input the right choice\n");
			eatline();
		}
		switch(input)
		{
			case 'a':
				{
					scanf("%lf",&w);
					w_yang+=w;
					break;
				}
			case 'b':
				{
					scanf("%lf",&w);
					w_tian+=w;
					break;
				}
			case 'c':
				{
					scanf("%lf",&w);
					w_hu+=w;
					break;
				}
			case 'q':
				{
					printf("exit\n");
					break;
				}
			default:
				break;
		}
		eatline();
		if('q' == input)
			break;
	}
	printf("***********************\n");
	printf("type\tweight\t\n");
	printf("yang\t%.2lf\t\n",w_yang);
	printf("tian\t%.2lf\t\n",w_tian);
	printf("hu\t%.2lf\n\t",w_hu);
	w_all = w_yang+w_tian+w_hu;
	printf("***********************\n");	
	if(w_all<=5)
		trans = low;
	else if(w_all>5 && w_all<=20)
		trans = medi;
	else
		trans = medi+(w_all-medi);
	sum = w_yang*yang+w_hu*hu+w_tian*tian;
	if(sum<=100)
		tic=0;
	else
		tic=sum*rate;
	printf("price\n");
	printf("***********************\n");
	printf("weight:\t%.2lf\t\n",w_all);
	printf("yang:\t%.2lf$\t\n",w_yang*yang);
	printf("tian:\t%.2lf$\t\n",w_tian*tian);
	printf("hu:\t%lf$\t\n",w_hu*hu);	
	printf("sum:\t%.2lf$\t\n",sum);
	printf("tic:\t%.2lf$\t\n",tic);
	printf("trans:\t%.2lf$\t\n",trans);
	printf("finally:\t%.2lf$\t\n",sum-tic+trans);
	printf("***********************\n");
	
	return 0;	
}

int eatline(void)
{
	while('\n' != getchar())
		continue;
	return 0;	
}
